package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.domain.dao.PublicGroupSeniorDao;
import com.xbongbong.saas.domain.dao.PublicGroupSeniorSortDao;
import com.xbongbong.saas.domain.entity.PublicGroupSeniorEntity;
import com.xbongbong.saas.domain.entity.PublicGroupSeniorSortEntity;
import com.xbongbong.saas.model.PublicGroupSeniorModel;
import com.xbongbong.saas.model.PublicGroupSeniorSortModel;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lijiangren
 * @date 2022/4/15 19:38
 */
@Service("publicGroupSeniorSortModel")
public class PublicGroupSeniorSortModelImpl implements PublicGroupSeniorSortModel {

    @Resource
    private PublicGroupSeniorSortDao publicGroupSeniorSortDao;

    @Override
    public void insertBatch(List<PublicGroupSeniorSortEntity> publicGroupSeniorSortEntityList) {
        publicGroupSeniorSortEntityList.forEach(item -> {
            long now = DateUtil.getInt();
            item.setAddTime(now);
            item.setUpdateTime(now);
            item.setDel(BasicConstant.ZERO);
        });
        publicGroupSeniorSortDao.insertBatch(publicGroupSeniorSortEntityList);
    }

    @Override
    public List<PublicGroupSeniorSortEntity> getListByFormIdAndCreatorId(String corpid, Long formId, String userId) {
        Map<String, Object> param = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        param.put("formId",formId);
        param.put("creatorId",userId);
        param.put("corpid",corpid);
        param.put("del", BasicConstant.ZERO);
        param.put("orderByStr", "sort asc");
        return findEntitys(param);
    }

    @Override
    public Integer updateBatch(List<PublicGroupSeniorSortEntity> list,String corpid) {
        list.forEach(item -> {
            long now = DateUtil.getInt();
            item.setUpdateTime(now);
        });
        return publicGroupSeniorSortDao.updateBatch(list,corpid);
    }

    @Override
    public Integer updateBatchDel(List<PublicGroupSeniorSortEntity> list,String corpid) {
        list.forEach(item -> {
            long now = DateUtil.getInt();
            item.setUpdateTime(now);
            item.setDel(BasicConstant.ONE);
        });
        return publicGroupSeniorSortDao.updateBatchDel(list,corpid);
    }

    @Override
    public List findEntitys(Map<String, Object> param) {
        return publicGroupSeniorSortDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer insert(PublicGroupSeniorEntity entity) throws XbbException {
        return null;
    }
    @Override
    public Integer update(PublicGroupSeniorEntity entity) throws XbbException {
        return null;
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

}
